From 93cc584dce5fba9c488ba1008d27168cc73559e5 Mon Sep 17 00:00:00 2001 From: Alec Brown Date: Wed, 22 Jan 2025 18:04:44 +0000 Subject: [PATCH] net: Check if returned pointer for allocated memory is NULL When using grub_malloc(), the function can fail if we are out of memory. After allocating memory we should check if this function returned NULL and handle this error if it did. Signed-off-by: Alec Brown Reviewed-by: Daniel Kiper Gbp-Pq: Topic cve-2025-jan Gbp-Pq: Name net-Check-if-returned-pointer-for-allocated-memory-is-NUL.patch --- grub-core/net/net.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index fb41d27..7ec4823 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -230,6 +230,11 @@ grub_net_ipv6_get_slaac (struct grub_net_card *card, } slaac->name = grub_malloc (sz); + if (slaac->name == NULL) + { + grub_free (slaac); + return NULL; + } ptr = grub_stpcpy (slaac->name, card->name); if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0) { -- 2.30.2